import Utils from '../../../../../utils/utils';

export const defualt = {
	isMustTran: "Y", //是否需要转成交报告
	isCustIntentionPlan: 'N', //是否客户按日提报 / 是否供应商按日提报
	effectiveTimeType: 'O',//资源有效时长
}

export const title = {
	area: {
		'P': '采购区域',
		'S': '销售区域'
	},
	plan: {
		'P': '计划采购量',
		'S': '计划销量'
	},
	number: {
		'P': '供应商销售数量',
		'S': '客户采购数量'
	},
	submission: {
		'P': '是否供应商按日提报',
		'S': '是否客户按日提报'
	}
}


/*
多轮 : M 
即买即中(推送摘单) : MZ
竞拍 : P
招标 : Z
需求判定 : DD
*/
export const showMap = {
	isFullPricesRequiredFn: (bizModel, goodsData) => { //是否所有价格必填
		return ((bizModel === 'Z' || bizModel == 'DD') && goodsData && goodsData.length > 1) ? true : false;
	},
	isFullPackageFixFn: (bizModel, goodsData) => { //是否整包提报
		return ((bizModel === 'Z' || bizModel == 'DD') && goodsData && goodsData.length > 1) ? true : false;
	},
	isSubmitPrepayFn: (bizModel) => { //是否缴纳保证金
		return bizModel == 'P' ? true : false;
	},
	isPriceFn: (bizModel) => { //	//含税单价
		return bizModel == 'M' || bizModel == 'MZ' ? true : false;
	},
	isOfferBottomPriceFn: (bizModel) => { //	//报盘底价
		return bizModel == 'P' || bizModel == 'Z' || bizModel == 'DD' ? true : false;
	},
	isCustPurNumFn: (bizModel) => { //	客户采购数量
		return bizModel == 'MZ' || bizModel == 'Z' || bizModel == 'DD' || bizModel == 'M' || bizModel == 'P' ? true : false;
	},
	isStepPriceFn: (bizModel) => { //	客户提报含税单价加价梯度
		return bizModel == 'P' ? true : false;
	},
	isBaseValueFn: (bizModel) => {  //摘单模式
		return bizModel != 'MZ' ? true : false;
	},
	isShowTip: (bizModel) => {  //是否展示“(低价)”提示  招标、需求判定、竞拍，
		return bizModel == 'Z' || bizModel == 'DD' || bizModel == 'P' ? true : false;
	}
}
export const mandatory = { // 必填
	isOfferBottomPriceFn: (bizModel) => { //	//报盘底价
		return bizModel == 'P' || bizModel == 'Z' ? true : false;
	}
}


export const veridateMap = {
	/* 全局必填 */
	mdtrIsUniteFn: (value) => {
		return Utils.isEmpty(value);
	}
}

export const initDate = { //编辑清空相关数据
	priceType: { //价格类型
		price: null,
		priceFormlaId: null,
		priceFormlaName: null,
		udPrice: null,
		symbol: true,
		offerBottomPrice: null
	},
	bizModel: function (data, bizModel) {
		if (!showMap.isFullPricesRequiredFn(bizModel)) { //是否所有价格必填
			data.isFullPricesRequired = null;
		}

		if (!showMap.isFullPackageFixFn(bizModel)) { //是否整包提报
			data.isFullPackageFix = null;
		}

		if (!showMap.isSubmitPrepayFn(bizModel)) { //是否缴纳保证金
			data.isSubmitPrepay = null;
			data.prepay = null;
		}
		//商品
		data.resourceApplyList && data.resourceApplyList.map((item) => {
			if (!showMap.isPriceFn(bizModel)) { //含税单价
				item.price = null;
			}
			if (!showMap.isOfferBottomPriceFn(bizModel)) { //报盘底价
				item.offerBottomPrice = null;
			}
			if (!showMap.isCustPurNumFn(bizModel)) { //客户采购数量
				item.custPurNum = null;
			}
			if (!showMap.isStepPriceFn(bizModel)) { //客户提报含税单价加价梯度
				item.stepPrice = null;
			}
			return item;
		})
		return data;
	},
	other: (sendData) => {
		console.log('9999', sendData)
		for (var key in sendData) {
			if (key === 'isSubmitPrepay' && sendData[key] === 'N') { //是否缴纳保证金
				sendData.prepay = null;
			}
			if (key === 'isCustIntentionPlan' && sendData[key] == 'N') {//是否供应商按日提报 客户采购数量
				sendData.intentionPlanBeginDate = null;
				sendData.intentionPlanEndDate = null;
			}
			if (key === 'effectiveTimeType' && sendData[key] == 'D') {//资源有效时段
				sendData.effectiveHour = null;
				sendData.effectiveMinute = null;
			}
		}
		return sendData;
	}
}

